<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>JSON Voorhees: Coercion</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" async src="http://www.mathjax.org/mathjax/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">JSON Voorhees
   </div>
   <div id="projectbrief">Killer JSON for C++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__Coercion.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Coercion</div>  </div>
</div><!--header-->
<div class="contents">

<p>Looser conversion functions to behave more like ECMAScript.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaf20cb82e10e2201d983e217c47e26ba6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#gaf20cb82e10e2201d983e217c47e26ba6">jsonv::can_coerce</a> (const <a class="el" href="group__Value.html#ga3721c2ed2f380809f2fc3b03a6f6fa53">kind</a> &amp;from, const <a class="el" href="group__Value.html#ga3721c2ed2f380809f2fc3b03a6f6fa53">kind</a> &amp;to)</td></tr>
<tr class="memdesc:gaf20cb82e10e2201d983e217c47e26ba6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Can the given <code>kind</code> be converted <em>from</em> a kind <em>to</em> another?  <a href="group__Coercion.html#gaf20cb82e10e2201d983e217c47e26ba6">More...</a><br /></td></tr>
<tr class="separator:gaf20cb82e10e2201d983e217c47e26ba6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafe7cfb78c4ebf72fe476ce5137b8538f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#gafe7cfb78c4ebf72fe476ce5137b8538f">jsonv::can_coerce</a> (const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;from, const <a class="el" href="group__Value.html#ga3721c2ed2f380809f2fc3b03a6f6fa53">kind</a> &amp;to)</td></tr>
<tr class="memdesc:gafe7cfb78c4ebf72fe476ce5137b8538f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Can the given <code>value</code> be converted <em>from</em> a kind <em>to</em> another?  <a href="group__Coercion.html#gafe7cfb78c4ebf72fe476ce5137b8538f">More...</a><br /></td></tr>
<tr class="separator:gafe7cfb78c4ebf72fe476ce5137b8538f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga82b464dbe1081e60ddcd82c434b28c34"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::nullptr_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#ga82b464dbe1081e60ddcd82c434b28c34">jsonv::coerce_null</a> (const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;from)</td></tr>
<tr class="memdesc:ga82b464dbe1081e60ddcd82c434b28c34"><td class="mdescLeft">&#160;</td><td class="mdescRight">Coerce <em>from</em> into a <code>null</code>.  <a href="group__Coercion.html#ga82b464dbe1081e60ddcd82c434b28c34">More...</a><br /></td></tr>
<tr class="separator:ga82b464dbe1081e60ddcd82c434b28c34"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae9a1f603c9ce75f7bd479f022e43dc91"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::map&lt; std::string, <a class="el" href="classjsonv_1_1value.html">value</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#gae9a1f603c9ce75f7bd479f022e43dc91">jsonv::coerce_object</a> (const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;from)</td></tr>
<tr class="memdesc:gae9a1f603c9ce75f7bd479f022e43dc91"><td class="mdescLeft">&#160;</td><td class="mdescRight">Coerce <em>from</em> into a <code>map</code>.  <a href="group__Coercion.html#gae9a1f603c9ce75f7bd479f022e43dc91">More...</a><br /></td></tr>
<tr class="separator:gae9a1f603c9ce75f7bd479f022e43dc91"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae17eed7144363cc743cf143f13c377c1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::vector&lt; <a class="el" href="classjsonv_1_1value.html">value</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#gae17eed7144363cc743cf143f13c377c1">jsonv::coerce_array</a> (const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;from)</td></tr>
<tr class="memdesc:gae17eed7144363cc743cf143f13c377c1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Coerce <em>from</em> into a <code>vector</code>.  <a href="group__Coercion.html#gae17eed7144363cc743cf143f13c377c1">More...</a><br /></td></tr>
<tr class="separator:gae17eed7144363cc743cf143f13c377c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7e3fd5c6922f9ead68a46031b0af3e49"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#ga7e3fd5c6922f9ead68a46031b0af3e49">jsonv::coerce_string</a> (const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;from)</td></tr>
<tr class="memdesc:ga7e3fd5c6922f9ead68a46031b0af3e49"><td class="mdescLeft">&#160;</td><td class="mdescRight">Coerce <em>from</em> into an <code>std::string</code>.  <a href="group__Coercion.html#ga7e3fd5c6922f9ead68a46031b0af3e49">More...</a><br /></td></tr>
<tr class="separator:ga7e3fd5c6922f9ead68a46031b0af3e49"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga202340832fcd5dc84ed142954bf4e85c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::int64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#ga202340832fcd5dc84ed142954bf4e85c">jsonv::coerce_integer</a> (const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;from)</td></tr>
<tr class="memdesc:ga202340832fcd5dc84ed142954bf4e85c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Coerce <em>from</em> into an integer.  <a href="group__Coercion.html#ga202340832fcd5dc84ed142954bf4e85c">More...</a><br /></td></tr>
<tr class="separator:ga202340832fcd5dc84ed142954bf4e85c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab8622e02fd1f38c93d11bc9680815627"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#gab8622e02fd1f38c93d11bc9680815627">jsonv::coerce_decimal</a> (const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;from)</td></tr>
<tr class="memdesc:gab8622e02fd1f38c93d11bc9680815627"><td class="mdescLeft">&#160;</td><td class="mdescRight">Coerce <em>from</em> into a <code>double</code>.  <a href="group__Coercion.html#gab8622e02fd1f38c93d11bc9680815627">More...</a><br /></td></tr>
<tr class="separator:gab8622e02fd1f38c93d11bc9680815627"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7ef79a40e8ad18e599287552546fca16"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#ga7ef79a40e8ad18e599287552546fca16">jsonv::coerce_boolean</a> (const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;from)</td></tr>
<tr class="memdesc:ga7ef79a40e8ad18e599287552546fca16"><td class="mdescLeft">&#160;</td><td class="mdescRight">Coerce <em>from</em> into a <code>bool</code>.  <a href="group__Coercion.html#ga7ef79a40e8ad18e599287552546fca16">More...</a><br /></td></tr>
<tr class="separator:ga7ef79a40e8ad18e599287552546fca16"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga98485441d78ea2cdfc00ce97b2563b73"><td class="memItemLeft" align="right" valign="top"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> <a class="el" href="classjsonv_1_1value.html">value</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Coercion.html#ga98485441d78ea2cdfc00ce97b2563b73">jsonv::coerce_merge</a> (<a class="el" href="classjsonv_1_1value.html">value</a> a, <a class="el" href="classjsonv_1_1value.html">value</a> b)</td></tr>
<tr class="memdesc:ga98485441d78ea2cdfc00ce97b2563b73"><td class="mdescLeft">&#160;</td><td class="mdescRight">Combines <em>a</em> and <em>b</em> in any way possible.  <a href="group__Coercion.html#ga98485441d78ea2cdfc00ce97b2563b73">More...</a><br /></td></tr>
<tr class="separator:ga98485441d78ea2cdfc00ce97b2563b73"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Looser conversion functions to behave more like ECMAScript. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="gaf20cb82e10e2201d983e217c47e26ba6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf20cb82e10e2201d983e217c47e26ba6">&#9670;&nbsp;</a></span>can_coerce() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> bool jsonv::can_coerce </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="group__Value.html#ga3721c2ed2f380809f2fc3b03a6f6fa53">kind</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__Value.html#ga3721c2ed2f380809f2fc3b03a6f6fa53">kind</a> &amp;&#160;</td>
          <td class="paramname"><em>to</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Can the given <code>kind</code> be converted <em>from</em> a kind <em>to</em> another? </p>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the corresponding <code>coerce_X</code> function for the specified <em>to</em> will successfully return if given a <code>value</code> of the kind <em>from</em>; false if there is no such conversion (the <code>coerce_X</code> function might throw). </dd></dl>

</div>
</div>
<a id="gafe7cfb78c4ebf72fe476ce5137b8538f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafe7cfb78c4ebf72fe476ce5137b8538f">&#9670;&nbsp;</a></span>can_coerce() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> bool jsonv::can_coerce </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__Value.html#ga3721c2ed2f380809f2fc3b03a6f6fa53">kind</a> &amp;&#160;</td>
          <td class="paramname"><em>to</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Can the given <code>value</code> be converted <em>from</em> a kind <em>to</em> another? </p>
<dl class="section note"><dt>Note</dt><dd>This is <em>not</em> only a convenience function! There is a special case for converting from a <code>string</code> into either a <code>decimal</code> or <code>integer</code> where the contents of the string must be considered. This function will look into the given <em>from</em> and see if it can successfully perfrom the coercion.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the corresponding <code>coerce_X</code> function for the specified <em>to</em> will successfully return if given the <code>value</code> <em>from</em>; false if there is no such conversion (the <code>coerce_X</code> function will throw). </dd></dl>

</div>
</div>
<a id="gae17eed7144363cc743cf143f13c377c1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae17eed7144363cc743cf143f13c377c1">&#9670;&nbsp;</a></span>coerce_array()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::vector&lt;<a class="el" href="classjsonv_1_1value.html">value</a>&gt; jsonv::coerce_array </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Coerce <em>from</em> into a <code>vector</code>. </p>
<dl class="section return"><dt>Returns</dt><dd>a vector of the contents of <em>from</em>. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></td><td>if <em>from</em> is not <code>kind::array</code>. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga7ef79a40e8ad18e599287552546fca16"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7ef79a40e8ad18e599287552546fca16">&#9670;&nbsp;</a></span>coerce_boolean()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> bool jsonv::coerce_boolean </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Coerce <em>from</em> into a <code>bool</code>. </p>
<p>This follows the rules of Python's boolean coercion.</p>
<dl class="section return"><dt>Returns</dt><dd><table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone"><code>kind</code> is...  </th><th class="markdownTableHeadNone">Rules ----------&mdash;   </th></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>null</code>  </td><td class="markdownTableBodyNone"><code>false</code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>object</code>  </td><td class="markdownTableBodyNone"><code>!from</code>.empty()   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>array</code>  </td><td class="markdownTableBodyNone"><code>!from</code>.empty()   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>string</code>  </td><td class="markdownTableBodyNone"><code>!from</code>.empty() (even if the value is <code>"false"</code>)   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>integer</code>  </td><td class="markdownTableBodyNone"><code>from</code> != 0   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>decimal</code>  </td><td class="markdownTableBodyNone"><code>from</code> != 0.0   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>boolean</code>  </td><td class="markdownTableBodyNone"><code>from.as_boolean()</code>   </td></tr>
</table>
</dd></dl>

</div>
</div>
<a id="gab8622e02fd1f38c93d11bc9680815627"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab8622e02fd1f38c93d11bc9680815627">&#9670;&nbsp;</a></span>coerce_decimal()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> double jsonv::coerce_decimal </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Coerce <em>from</em> into a <code>double</code>. </p>
<dl class="section return"><dt>Returns</dt><dd><table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone"><code>kind</code> is...  </th><th class="markdownTableHeadNone">Rules ----------&mdash;   </th></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>null</code>  </td><td class="markdownTableBodyNone">throws <code><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>object</code>  </td><td class="markdownTableBodyNone">throws <code><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>array</code>  </td><td class="markdownTableBodyNone">throws <code><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>string</code>  </td><td class="markdownTableBodyNone"><code>parse</code>(from.as_string()).as_decimal()   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>integer</code>  </td><td class="markdownTableBodyNone"><code>from.as_decimal()</code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>decimal</code>  </td><td class="markdownTableBodyNone"><code>from.as_decimal()</code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>boolean</code>  </td><td class="markdownTableBodyNone"><code>from.as_boolean()</code> ? 1.0 : 0.0   </td></tr>
</table>
</dd></dl>

</div>
</div>
<a id="ga202340832fcd5dc84ed142954bf4e85c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga202340832fcd5dc84ed142954bf4e85c">&#9670;&nbsp;</a></span>coerce_integer()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::int64_t jsonv::coerce_integer </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Coerce <em>from</em> into an integer. </p>
<p>If <em>from</em> is a <code>decimal</code> lower than the minimum of <code>std::int64_t</code> or higher than the maximum of <code>std::int64_t</code>, it is clamped to the lowest or highest value, respectively.</p>
<dl class="section return"><dt>Returns</dt><dd><table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone"><code>kind</code> is...  </th><th class="markdownTableHeadNone">Rules ----------&mdash;   </th></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>null</code>  </td><td class="markdownTableBodyNone">throws <code><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>object</code>  </td><td class="markdownTableBodyNone">throws <code><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>array</code>  </td><td class="markdownTableBodyNone">throws <code><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>string</code>  </td><td class="markdownTableBodyNone"><code>parse</code>(from.as_string()).as_integer()   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>integer</code>  </td><td class="markdownTableBodyNone"><code>from.as_integer()</code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>decimal</code>  </td><td class="markdownTableBodyNone"><code>std::int64_t</code>(from.as_decimal())   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>boolean</code>  </td><td class="markdownTableBodyNone"><code>from.as_boolean()</code> ? 1 : 0   </td></tr>
</table>
</dd></dl>

</div>
</div>
<a id="ga98485441d78ea2cdfc00ce97b2563b73"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga98485441d78ea2cdfc00ce97b2563b73">&#9670;&nbsp;</a></span>coerce_merge()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> <a class="el" href="classjsonv_1_1value.html">value</a> jsonv::coerce_merge </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classjsonv_1_1value.html">value</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classjsonv_1_1value.html">value</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Combines <em>a</em> and <em>b</em> in any way possible. </p>
<p>The result kind is <em>usually</em> based on the kind of <em>a</em> and loosely follows what ECMAScript does when you call <code>+</code> on two values (sort of). If you are looking for "predictable", this is not the function for you. If you are looking for convenience, this is it. </p>

</div>
</div>
<a id="ga82b464dbe1081e60ddcd82c434b28c34"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga82b464dbe1081e60ddcd82c434b28c34">&#9670;&nbsp;</a></span>coerce_null()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::nullptr_t jsonv::coerce_null </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Coerce <em>from</em> into a <code>null</code>. </p>
<p>If <em>from</em> is not <code>null</code>, this will throw. It is not clear that there is a use for this beyond completeness.</p>
<dl class="section return"><dt>Returns</dt><dd><code>nullptr</code> if <em>from</em> has <code>kind::null</code>. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></td><td>if <em>from</em> is not <code>kind::null</code>. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gae9a1f603c9ce75f7bd479f022e43dc91"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae9a1f603c9ce75f7bd479f022e43dc91">&#9670;&nbsp;</a></span>coerce_object()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::map&lt;std::string, <a class="el" href="classjsonv_1_1value.html">value</a>&gt; jsonv::coerce_object </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Coerce <em>from</em> into a <code>map</code>. </p>
<dl class="section return"><dt>Returns</dt><dd>a map of the contents of <em>from</em>. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classjsonv_1_1kind__error.html" title="Thrown from various value methods when attempting to perform an operation which is not valid for the ...">kind_error</a></td><td>if <em>from</em> is not <code>kind::object</code>. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga7e3fd5c6922f9ead68a46031b0af3e49"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7e3fd5c6922f9ead68a46031b0af3e49">&#9670;&nbsp;</a></span>coerce_string()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="config_8hpp.html#acd0703012bd724b356c177b7bc3d761d">JSONV_PUBLIC</a> std::string jsonv::coerce_string </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classjsonv_1_1value.html">value</a> &amp;&#160;</td>
          <td class="paramname"><em>from</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Coerce <em>from</em> into an <code>std::string</code>. </p>
<p>If <em>from</em> is already <code>kind::string</code>, the value is simply returned. If <em>from</em> is any other <code>kind</code>, the result will be the same as <code>to_string</code>. </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
